package yu.com.telecontroller;

import java.util.HashMap;

import android.app.Activity;
import android.app.Service;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;
import android.app.Service;  
import android.content.Context;
import android.os.Vibrator; 
import android.widget.Toast;

public class TVActivity extends Activity {
    /** Called when the activity is first created. */
	
//	private ImageButton mOnOff;
//	private ImageButton mMute;
//	private ImageButton mNumber1;
//	private ImageButton mNumber2;
//	private ImageButton mNumber3;
//	private ImageButton mNumber4;
//	private ImageButton mNumber5;
//	private ImageButton mNumber6;
//	private ImageButton mNumber7;
//	private ImageButton mNumber8;
//	private ImageButton mNumber9;
//	private ImageButton mNumber0;
//	private ImageButton mInput;
//	private ImageButton mBack;
//	private ImageButton mNumbervolup;
//	private ImageButton mNumbervoldown;
//	private ImageButton mMenu;
//	private ImageButton mNumberprev;
//	private ImageButton mNumbernext;	
//	private Toast 		 mToast = null;
//	private Vibrator m_Vib = null;
//	private SoundPool mSoundPool = null;
//	private HashMap <Integer, Integer> mNumberMap = null;   
//	
//	private int [] mCodeVolup = 	{0x12,0x11,0x38,0xff,0xff,0x00,0xa8,0xaa,0xa2,0x28,0x88,0x88,0x8a,0x22,0xaa,0x8a,0x88,0x88,0x80}; 
//	private int [] mCodeVoldown = 	{0x12,0x11,0x38,0xff,0xff,0x00,0xa8,0xaa,0xa2,0x28,0x88,0x88,0x8a,0x28,0xaa,0x8a,0x28,0x88,0x80};
//	private int [] mCodeInput = 	{0x12,0x11,0x38,0xff,0xff,0x00,0xa8,0xaa,0xa2,0x28,0x88,0x88,0x88,0x8a,0x28,0xaa,0x8a,0x28,0x80};
//	private int [] mCodePowon = 	{0x12,0x11,0x38,0xff,0xff,0x00,0xa8,0xaa,0xa2,0x28,0x88,0x88,0xa2,0x2a,0x8a,0xa2,0x22,0x28,0x80};
//	private int [] mCodeMute = 		{0x12,0x11,0x38,0xff,0xff,0x00,0xa8,0xaa,0xa2,0x28,0x88,0x88,0xa8,0xaa,0xa2,0xaa,0x88,0x88,0x80};

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
//        mOnOff = (ImageButton)findViewById(R.id.button_on);
//        mMute = (ImageButton)findViewById(R.id.button_mute);
//        mNumber1 = (ImageButton)findViewById(R.id.ImageButton1);
//        mNumber2 = (ImageButton)findViewById(R.id.ImageButton2);
//        mNumber3 = (ImageButton)findViewById(R.id.ImageButton3);
//        mNumber4 = (ImageButton)findViewById(R.id.ImageButton4);
//        mNumber5 = (ImageButton)findViewById(R.id.ImageButton5);
//        mNumber6 = (ImageButton)findViewById(R.id.ImageButton6);
//        mNumber7 = (ImageButton)findViewById(R.id.ImageButton7);
//        mNumber8 = (ImageButton)findViewById(R.id.ImageButton8);
//        mNumber9 = (ImageButton)findViewById(R.id.ImageButton9);
//        mNumber0 = (ImageButton)findViewById(R.id.ImageButton0);
//        mInput = (ImageButton)findViewById(R.id.ImageButton_);
//        mBack = (ImageButton)findViewById(R.id.ImageButton_back);
//        mNumbervolup = (ImageButton)findViewById(R.id.ImageButton_add);
//        mNumbervoldown = (ImageButton)findViewById(R.id.ImageButton_reduce);
//        mNumberprev = (ImageButton)findViewById(R.id.ImageButton_prev);
//        mNumbernext = (ImageButton)findViewById(R.id.ImageButton_next);
//        mMenu = (ImageButton)findViewById(R.id.ImageButton_menu);
//        
//        SoundPool mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC,100); 
//        mNumberMap = new HashMap<Integer, Integer>();   
//
////        mNumberMap.put(0, mSoundPool.load(getBaseContext(),R.raw.num_0,1));
////        mNumberMap.put(1, mSoundPool.load(getBaseContext(),R.raw.num_1,1));
////        mNumberMap.put(2, mSoundPool.load(getBaseContext(),R.raw.num_2,1));
////        mNumberMap.put(3, mSoundPool.load(getBaseContext(),R.raw.num_3,1));
////        mNumberMap.put(4, mSoundPool.load(getBaseContext(),R.raw.num_4,1));
////        mNumberMap.put(5, mSoundPool.load(getBaseContext(),R.raw.num_5,1));
////        mNumberMap.put(6, mSoundPool.load(getBaseContext(),R.raw.num_6,1));
////        mNumberMap.put(7, mSoundPool.load(getBaseContext(),R.raw.num_7,1));
////        mNumberMap.put(8, mSoundPool.load(getBaseContext(),R.raw.num_8,1));
////        mNumberMap.put(9, mSoundPool.load(getBaseContext(),R.raw.num_9,1));
////        mNumberMap.put(10, mSoundPool.load(getBaseContext(),R.raw.num_a,1));
////        mNumberMap.put(11, mSoundPool.load(getBaseContext(),R.raw.num_b,1));
////        mNumberMap.put(12, mSoundPool.load(getBaseContext(),R.raw.num_c,1));
////        mNumberMap.put(13, mSoundPool.load(this,R.raw.num_d,1));
////        mNumberMap.put(14, mSoundPool.load(this,R.raw.num_e,1));
////        mNumberMap.put(15, mSoundPool.load(this,R.raw.num_f,1));
//        mNumberMap.put(16, mSoundPool.load(getApplicationContext(),R.raw.number1,0));
//
//        mOnOff.setVisibility(View.VISIBLE);
//        mMute.setVisibility(View.VISIBLE);
//        mNumber1.setVisibility(View.VISIBLE);
//        mNumber2.setVisibility(View.VISIBLE);
//        mNumber3.setVisibility(View.VISIBLE);
//        mNumber4.setVisibility(View.VISIBLE);
//        mNumber5.setVisibility(View.VISIBLE);
//        mNumber6.setVisibility(View.VISIBLE);
//        mNumber7.setVisibility(View.VISIBLE);
//        mNumber8.setVisibility(View.VISIBLE);
//        mNumber9.setVisibility(View.VISIBLE);
//        mNumber0.setVisibility(View.VISIBLE);
//        mInput.setVisibility(View.VISIBLE);
//        mBack.setVisibility(View.VISIBLE);        
//        mNumbervolup.setVisibility(View.VISIBLE);
//        mNumbervoldown.setVisibility(View.VISIBLE);
//        mNumberprev.setVisibility(View.VISIBLE);
//        mNumbernext.setVisibility(View.VISIBLE);
//        mMenu.setVisibility(View.VISIBLE);
//        
//        m_Vib = (Vibrator) this.getSystemService(Service.VIBRATOR_SERVICE);  
//       
//
//        mOnOff.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				PlayButtonCode(mCodePowon);
//				TipButton("power on");
//			}
//		});
//        mMute.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				PlayButtonCode(mCodeMute);
//				TipButton("mute");
//			}
//		});
//        mNumber1.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 1");
//			}
//		});
//        mNumber2.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton(" number 2");
//			}
//		});
//        mNumber3.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 3");
//			}
//		});
//        mNumber4.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 4");
//			}
//		});
//        mNumber5.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 5");
//			}
//		});
//        mNumber6.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 6");
//			}
//		});
//        mNumber7.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 7");
//			}
//		});
//        mNumber8.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 8");
//			}
//		});
//        mNumber9.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("number 9");
//			}
//		});
//        mNumber0.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				PlayButtonCode(mCodeVoldown);
//				TipButton("number 0");
//			}
//		});
//        mNumbervolup.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				PlayButtonCode(mCodeVolup);
//				TipButton("vol up");
//			}
//		});
//        mInput.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				PlayButtonCode(mCodeInput);
//				TipButton("input");
//			}
//		});
//        mBack.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("back");
//			}
//		});        
//        mNumbervoldown.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("vol down");
//			}
//		});
//        mNumberprev.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("prev");
//			}
//		});
//        mNumbernext.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("next");
//			}
//		});
//        mMenu.setOnClickListener(new View.OnClickListener() {
//			
//			public void onClick(View v) {
//				// TODO Auto-generated method stub
//				TipButton("menu");
//			}
//		});
//        
//    }
//    public void TipButton(String tip)
//    {
//		m_Vib.vibrate(50);
//		if(mToast != null)
//			mToast.cancel();
//		mToast = Toast.makeText(this, tip, Toast.LENGTH_SHORT); 
//		mToast.show();      	
//    }
//    public void PlayByteCode(int code)
//    {
//    	int p1 = (code >> 4) & 0x0f;
//    	int p2 = code & 0xf;
//        AudioManager mgr = (AudioManager) this.getSystemService(   
//                Context.AUDIO_SERVICE);  
//        int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);   
//    	if(p1 == p2)
//    		mSoundPool.play(mNumberMap.get(16), streamVolume, streamVolume, 0, 1, 1f);
//    	else
//    	{
//    		mSoundPool.play(mNumberMap.get(16),streamVolume,streamVolume, 0, 0, 1f);
//    		//mSoundPool.play(mNumberMap.get(16),streamVolume,streamVolume, 1, 0, 1f);
//    	}
//    }
//    public void PlayButtonCode(int [] code)
//    {
//    	for(int i = 0; i < code.length;i++)
//    	{
//    		PlayByteCode(code[i]);
//    	}
//    }
    }
}